package com.sunnyweather.android.ui.city

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations
import androidx.lifecycle.ViewModel
import com.sunnyweather.android.logic.Repository
import com.sunnyweather.android.logic.model.City

class CityViewModel : ViewModel() {
    private val searchLiveData = MutableLiveData<String>()

    val cityList = ArrayList<City>()

    val placeLiveData = Transformations.switchMap(searchLiveData) { query ->
        Repository.searchCities(query)
    }

    fun searchCities(query: String) {
        searchLiveData.value = query
    }
}